<template>
	<view v-if="friend.companyId" class="friend-item" @click="click">
		<up-checkbox v-if="showCheck" :customStyle="{ marginRight: '10rpx' }" :checked="checked" :disabled="disabled" />
		<head-image :name="friend.friendNickName" :online="friend.online" :url="friend.friendHeadImage" :size="90"></head-image>
		<view class="friend-info">
			<view class="friend-name">{{ friend.friendNickName }}</view>
		</view>
	</view>
	<view v-else class="friend-item" @click="click">
		<up-checkbox v-if="showCheck" :customStyle="{ marginRight: '10rpx' }" :checked="checked" :disabled="disabled" />
		<head-image :name="friend.nickName" :online="friend.online" :url="friend.headImage" :size="90"></head-image>
		<view class="friend-info">
			<view class="friend-name">{{ friend.nickName }}</view>
		</view>
	</view>
</template>

<script>
import chatStore from '@/store/chatStore'
export default {
	name: "frined-item",
	data() {
		return {}
	},
	methods: {
		click() {
			console.log('跳转',this.friend)
			if(this.friend.nickName == "友星缘助手"){
				uni.navigateTo({
					url:"/pageSubOne/friend/friend-helper"
				})
				return
			}
			this.$emit("click", this.friend)
			const type = this.sourceType == 0 ? this.chatStore.chatType.PRIVATE : this.chatStore.chatType.BUSINESS
			this.chatStore.openChatRedirect(type, this.friend.id, {
				sourceType: this.sourceType
			})
			// uni.navigateTo({
			// 	url: "/pageSubOne/common/user-info?id=" + this.friend.id
			// })
		},
	},
	props: {
		friend: {
			type: Object
		},
		sourceType: {
			type: Number,
			default: 0,
			required: true
		},
		showCheck: {
			type: Boolean,
			default: false
		},
		checked: {
			type: Boolean,
			default: false
		},
		disabled: {
			type: Boolean,
			default: false
		}
	}
}
</script>

<style scope lang="scss">
.friend-item {
	height: 100rpx;
	display: flex;
	margin-bottom: 1rpx;
	position: relative;
	padding: 10rpx;
	padding-left: 20rpx;
	align-items: center;
	background-color: white;
	white-space: nowrap;

	.friend-info {
		flex: 1;
		display: flex;
		flex-direction: column;
		padding-left: 20rpx;
		text-align: left;

		.friend-name {
			font-size: 30rpx;
			font-weight: 600;
			line-height: 60rpx;
			white-space: nowrap;
			overflow: hidden;
		}

		.friend-online {
			.online {
				padding-right: 4rpx;
				width: 32rpx;
				height: 32rpx;

			}
		}
	}
}
</style>